package day8;

import java.util.Scanner;

public interface Music {
    String name="大帅哥";
    void play();
}
//extends 必须保证类和类，接口和接口才可以
//implements 用于类和接口
class Erhu implements Music {
    public void play(){
        System.out.println("乐手"+name+"在演奏二胡！");
    }
}

class Piano implements Music {
    public void play(){
        System.out.println("乐手"+name+"在演奏钢琴!");
    }
}

class Violin implements Music {
    public void play(){
        System.out.println("乐手"+name+"在演奏小提琴!");
    }
}

class Test1{
    public static void main(String[] args) {
        Music m=null;
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入你喜欢的乐器（1.二胡，2.钢琴，3.小提琴）:");
        int n=sc.nextInt();
        switch (n){
            case 1:
                m=new Erhu();
                break;
            case 2:
                m=new Piano();
                break;
            case 3:
                m=new Violin();
                break;
            default:break;
        }
        m.play();
    }
}